<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{$Think.config.site.title} - 更新设备配置文件</title>
    <meta name="keywords" content="{$Think.config.site.keywords}">
    <meta name="description" content="{$Think.config.site.description}">
    <link href="{$Think.config.site.resource_url}css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/animate.min.css" rel="stylesheet">
    <link href="{$Think.config.site.resource_url}css/style.min.css?v=4.0.0" rel="stylesheet">
</head>
<body class="gray-bg">
    <div id="show">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">

                        <?php if(isset($v)){?>
                        <div class="ibox-content">
                            <form method="post" class="form-horizontal" id="myfoms">
                            <div class="alert ">
                                <input type="hidden" name="cabinet_id" value="{$v}">
                                <p>{:lang('服务器地址')}：<input type="text" class="form-control" name="servicer" required="required" ></p>
                                <br/>
                                <p>{:lang('服务器端口')}：<input type="text" class="form-control" name="port" required="required" pattern="/^d+$/"></p>
                                <br/>
                                <p>{:lang('心跳间隔：(单位/秒)')}<input type="text" class="form-control" name="heartbeat" required="required" pattern="/^d+$/"> </p>
                                <br>
                                <p><button class="btn btn-primary " type="button" id="bton"><i class="fa fa-check"></i>&nbsp;{:lang('更新配置文件信息')}&nbsp;</button></p>
                            </div>
                            </form>
                        </div>
                        <?php }else{ ?>
                            <div class="ibox-content">
                            <br/><br/><br/>
                                <h3 style="text-align: center;">{:lang('非法访问')}!</h3>
                            </div>
                        <?php } ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="{$Think.config.site.resource_url}js/jquery.min.js?v=2.1.4"></script>
    <script src="{$Think.config.site.resource_url}js/bootstrap.min.js?v=3.3.5"></script>
    <script src="{$Think.config.site.resource_url}js/plugins/layer/layer.js"></script>
    <script type="text/javascript">
        $(function(){
            $('#bton').click(function(){
                var formdata = $('#myfoms').serialize();
                $.ajax({
                    type : 'POST',
                    url  : '<?php echo \think\Request::instance()->root(); ?>/<?php echo \think\Request::instance()->module(); ?>/Equipment/updateconf',
                    dataType : 'json',
                    data : formdata,
                    async : false,
                    success : function(result){
                        if(0 == result.code){
                            layer.msg("{:lang('更新成功！')}", {icon: 1});
                            parent.location.reload();
                        }else{
                            layer.msg("{:lang('更新失败！')}", {icon: 5});
                        }
                    },
                    error : function(){
                        layer.msg("{:lang('服务器错误！请稍后重试')}", {icon: 2});
                    }
                })
            });
        });
    </script>
</body>
</html>